<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.copy-btn {
	padding-left: 4px;
	cursor: pointer;
}

.viewer-container {
	z-index: 9999 !important;
}

.view-unused-btn {
	margin-left: 4px;
}
</style>
</head>
<body>
	<script src="https://cdn.staticfile.org/dayjs/1.7.8/dayjs.min.js"></script>
	<script src="https://cdn.staticfile.org/clipboard.js/2.0.4/clipboard.min.js"></script>
	<link href="https://cdn.staticfile.org/viewerjs/1.3.3/viewer.min.css" rel="stylesheet">
	<script src="https://cdn.staticfile.org/viewerjs/1.3.3/viewer.min.js"></script>
	<div th:replace="common/header::html"></div>
	<div id="q-app">
		<q-dialog persistent v-model="showExchangeRecordDialogFlag"> <q-card style="min-width: 750px;"> <q-card-section class="row items-center q-pb-none">
		<div class="text-h6">兑换记录</div>
		<q-space></q-space> <q-btn icon="close" flat round dense v-close-popup></q-btn> </q-card-section> <q-card-section class="q-pt-none">
		<div class="q-gutter-md q-pb-md row">
			<q-input outlined v-model="memberMobile" label="手机号" :dense="true"></q-input>
			<q-btn color="primary" label="查询" @click="findExchangeRecord"></q-btn>
		</div>
		<q-markup-table style="height: 450px"> <template>
		<thead>
			<tr>
				<th class="text-left">会员信息</th>
				<th class="text-left">艺术品编号</th>
				<th class="text-left">兑换代码</th>
				<th class="text-left">兑换时间</th>
			</tr>
		</thead>
		</template> <template>
		<tbody>
			<tr v-for="data in exchangeRecords">
				<td class="text-left">
					<div>手机号:{{data.memberMobile}}</div>
					<div>
						区块链地址:<span class="hash-info">{{data.memberBlockChainAddr}}</span>
					</div>
				</td>
				<td class="text-left">#{{data.collectionSerialNumber}}</td>
				<td class="text-left">{{data.code}}</td>
				<td class="text-left">{{data.exchangeTime}}</td>
			</tr>
		</tbody>
		</template> </q-markup-table> </q-card-section> </q-card> </q-dialog>

		<q-dialog persistent v-model="exchangeCodeDialogFlag"> <q-card style="min-width: 320px;"> <q-card-section class="row items-center q-pb-none">
		<div class="text-h6">有效兑换码</div>
		<q-space></q-space> <q-btn icon="close" flat round dense v-close-popup></q-btn> </q-card-section> <q-card-section class="q-pt-none"> <q-markup-table style="height: 400px"> <template>
		<thead>
			<tr>
				<th class="text-left">兑换代码</th>
				<th class="text-left">创建时间</th>
				<th class="text-left">有效期</th>
			</tr>
		</thead>
		</template> <template>
		<tbody>
			<tr v-for="exchangeCode in exchangeCodes">
				<td class="text-left">{{exchangeCode.code}}</td>
				<td class="text-left">{{exchangeCode.createTime}}</td>
				<td class="text-left">{{exchangeCode.effectiveTime}}</td>
			</tr>
		</tbody>
		</template> </q-markup-table> </q-card-section> </q-card> </q-dialog>

		<q-dialog persistent v-model="showAddDialogFlag"> <q-card style="min-width: 350px;"> <q-card-section class="row items-center q-pb-none">
		<div class="text-h6">生成兑换码</div>
		<q-space></q-space> <q-btn icon="close" flat round dense v-close-popup></q-btn> </q-card-section> <q-card-section class="q-pt-none"> <q-form class="q-gutter-md"> <q-select outlined
			v-model="generateExchangeCode.collectionId" emit-value map-options :options="collections" option-value=id option-label="name" :dense="true" label="兑换的艺术品"> </q-select> <q-input outlined
			type="number" v-model="generateExchangeCode.quantity" label="数量" :dense="true"></q-input> <q-input outlined type="number" v-model="generateExchangeCode.effectiveDays" label="有效期(天数)，不填则永不过期"
			:dense="true"></q-input> </q-form> </q-card-section> <q-card-actions align="right"> <q-btn label="保存" color="primary" @click="add"></q-btn> </q-card-actions> </q-card> </q-dialog>
		<div class="q-pa-md">
			<q-table color="primary" :data="tableData" :columns="tableColumns" :pagination.sync="tablePagination" :rows-per-page-options="[10, 30, 50, 100]" :loading="tableDataLoading" @request="loadTableData">
			<template v-slot:top-left> </template> <template v-slot:top-right>
			<div class="q-gutter-md row">
				<q-btn outline color="primary" label="生成兑换码" @click="showAddDialog"></q-btn>
			</div>
			</template> <template v-slot:body-cell-collection_info="props"> <q-td :props="props">
			<div style="display: flex; align-items: center;">
				<div>
					<img :src="props.row.collectionCover" style="height: 50px; width: 50px; object-fit: contain;">
				</div>
				<div style="padding-left: 4px;">
					<div>{{props.row.collectionName}}</div>
				</div>
			</div>
			</q-td> </template> <template v-slot:body-cell-unused_count="props"> <q-td :props="props">
			<div>
				{{props.row.unusedCount}}
				<q-btn size="xs" color="secondary" label="查看" class="view-unused-btn" @click="showExchangeCodeDialog(props.row.id)"></q-btn>
			</div>
			</q-td> </template> <template v-slot:body-cell-action="props"> <q-td :props="props">
			<div class=" q-gutter-sm">
				<q-btn color="primary" label="兑换记录" @click="showExchangeRecordDialog(props.row.id)"></q-btn>
				<q-btn-dropdown color="primary" label="更多"> <q-list> <q-item clickable v-close-popup @click="invalid(props.row.id)"> <q-item-section> <q-item-label>全部作废</q-item-label>
				</q-item-section> </q-item> </q-list> </q-btn-dropdown>
			</div>
			</q-td> </template> <template v-slot:loading> <q-inner-loading showing color="primary"></q-inner-loading> </template> </q-table>
		</div>
	</div>
	<script src="/js/exchange-code.js"></script>
</body>
</html>